<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>编辑需求申请</title>
<jsp:include page="../../pages/head.jsp" />
<script type="text/javascript" src="<%=path %>/js/ueditor/editor_all_min.js"></script>
<script type="text/javascript" src="<%=path %>/js/ueditor/editor_config.js"></script>
<link rel="stylesheet" type="text/css" href="<%=path %>/js/ueditor/themes/default/ueditor.css" />
<link rel="stylesheet" type="text/css" media="screen" href="<%=path %>/js/jquery.combogrid/resources/css/smoothness/jquery-ui-1.10.1.custom.css"/>
<script type="text/javascript" src="<%=path %>/js/jquery.combogrid/resources/jquery/jquery-ui-1.10.1.custom.min.js"></script>
<link rel="stylesheet" type="text/css" media="screen" href="<%=path %>/js/jquery.combogrid/resources/css/smoothness/jquery.ui.combogrid.css"/>
<script type="text/javascript" src="<%=path %>/js/jquery.combogrid/resources/plugin/jquery.ui.combogrid-1.6.3.js"></script>
<script type="text/javascript">

	function save(){
		$("#demindApplyContent").val("");
		if (!checkForm(document.getElementById("saveForm"))) {
			return;
		}
		$("#demindApplyContent").val(editor.getContent());
		xbox.load("loading");	
		$("#saveForm").ajaxSubmit({
			success: function(date){
			 	xbox.ready("loading");
				if(date=="数据保存成功"){
					j_tip(date,"success");
		    		$("#refreshForm").submit();
				}else
					j_tip(date,"error");
	    	},
		    error:function(){
		    	xbox.ready("loading");
		    	j_tip("保存数据超时或网络问题,请尝试重新登录.","error");
		    }
		 });
	}
	function turnBack(){
	   $("#refreshForm").submit();
	}
	var editor = null;
	$(function(){
		editor = new baidu.editor.ui.Editor({
            allHtmlEnabled:true
    	});
		editor.render('baiduEditor');
		$( "#area" ).combogrid({
			url: '<%=path%>/area/areaAjax_query4AutoComplete_resourceAction.action?t='+t,
			debug:false,
			colModel: [{'columnName':'areaId','width':'15','label':'编号'}, {'columnName':'areaName','width':'40','label':'办事处名称'},{'columnName':'areaDutyuserName','width':'40','label':'负责人'}],
			select: function( event, ui ) {
				$(this).val(ui.item.areaName);
				var areaId = $("#areaId").val();
				if(areaId!="" && parseInt(areaId)==ui.item.areaId)
					return false;
				$("#areaId").val(ui.item.areaId);
				$("#demindApplyDutyuser").val(ui.item.areaDutyuser.realName);
				$("#demindApplyDutyuserId").val(ui.item.areaDutyuser.userId);
				$("#clientId,#client,#demindApplyUser,#demindApplyUserId").val("");
				$("#clientHide,#demindApplyDutyuserHide,#demindApplyUserHide").hide();
				$("#client,#demindApplyDutyuser,#demindApplyUser").show();
				return false;
			},inputSpace:function(){
				$("#clientId,#client,#areaId,#demindApplyDutyuser,#demindApplyDutyuserId,#demindApplyUser,#demindApplyUserId").val("");
				$("#clientHide,#demindApplyDutyuserHide,#demindApplyUserHide").show();
				$("#client,#demindApplyDutyuser,#demindApplyUser").hide();
			}
		});
		$( "#client" ).combogrid({
			url: '<%=path%>/client/clientAjax_query4AutoComplete_resourceAction.action?t='+t,
			debug:false,
			getParams: function(){return "&areaId="+$("#areaId").val()},
			colModel: [{'columnName':'clientId','width':'15','label':'编号'}, {'columnName':'clientName','width':'40','label':'客户名称'},{'columnName':'areaName','width':'40','label':'办事处'}],
			select: function( event, ui ) {
				$(this).val(ui.item.clientName);
				$("#clientId").val(ui.item.clientId);
				return false;
			},inputSpace:function(){
				$("#clientId").val("");
			}
		});
		$( "#demindApplyDutyuser" ).combogrid({
			url: '<%=path%>/user/userAjax_query4AutoComplete_resourceAction.action?t='+t,
			debug:false,
			getParams: function(){return "&areaId="+$("#areaId").val()},
			colModel: [{'columnName':'id','width':'15','label':'编号'}, {'columnName':'name','width':'40','label':'员工姓名'},{'columnName':'departmentName','width':'40','label':'所属部门'}],
			select: function( event, ui ) {
				$(this).val(ui.item.name);
				$("#demindApplyDutyuserId").val(ui.item.id);
				return false;
			},
			inputSpace:function(){
				$("#demindApplyDutyuserId").val("");
			}
		});
		$( "#demindApplyUser" ).combogrid({
			url: '<%=path%>/user/userAjax_query4AutoComplete_resourceAction.action?t='+t,
			debug:false,
			getParams: function(){return "&areaId="+$("#areaId").val()},
			colModel: [{'columnName':'id','width':'15','label':'编号'}, {'columnName':'name','width':'40','label':'员工姓名'},{'columnName':'departmentName','width':'40','label':'所属部门'}],
			select: function( event, ui ) {
				$(this).val(ui.item.name);
				$("#demindApplyUserId").val(ui.item.id);
				return false;
			},
			inputSpace:function(){
				$("#demindApplyUserId").val("");
			}
		});
		$("#clientHide,#demindApplyDutyuserHide,#demindApplyUserHide").focus(function(){
			addError($("#area"),"请先选择办事处");
		});
		$("#project").combogrid({
			url: '<%=path%>/project/projectAjax_query4AutoComplete_resourceAction.action?t='+t,
			debug:false,
			colModel: [{'columnName':'projectId','width':'15','label':'编号'}, {'columnName':'projectName','width':'40','label':'项目名称'},{'columnName':'projectDutyuserName','width':'40','label':'负责人'}],
			select: function( event, ui ) {
				$(this).val(ui.item.projectName);
				$("#projectId").val(ui.item.projectId);
				$("#demindSolveDutyuser").val(ui.item.projectDutyuser.realName);
				$("#demindSolveDutyuserId").val(ui.item.projectDutyuser.userId);
				return false;
			},
			inputSpace:function(){
				$("#demindSolveDutyuserId").val("");
			}
		});
		$("#demindSolveDutyuser").combogrid({
			url: '<%=path%>/user/userAjax_query4AutoComplete_resourceAction.action?t='+t,
			debug:false,
			colModel: [{'columnName':'id','width':'15','label':'编号'}, {'columnName':'name','width':'40','label':'员工姓名'},{'columnName':'departmentName','width':'40','label':'所属部门'}],
			select: function( event, ui ) {
				$(this).val(ui.item.name);
				$("#demindSolveDutyuserId").val(ui.item.id);
				return false;
			},
			inputSpace:function(){
				$("#demindSolveDutyuserId").val("");
			}
		});
	});

</script>

</head>
<body>
<form action="<%=path%>/demindapply/demindapplyAjax_modify_msgAction.action" method="post" id="saveForm">
<table width="99%" align="center" border="0" cellpadding="4" cellspacing="1" bgcolor="#F1F1F1" style="margin-bottom:8px">
  <tr>
    <td colspan="6" height="16"><span></span></td>
  </tr>
  <tr>
  	<td width="9%" align="right" >需求级别：</td>
    <td width="24%" align="left" >
        <select name="demindApply.demindLevel.demindLevelId" style='width:150px'>
			<c:forEach items="${listDemindLevel}" var="o">
          		<option value="${o.demindLevelId}" <c:if test="${o.demindLevelId eq demindApply.demindLevel.demindLevelId}">selected="selected"</c:if>>${o.demindLevelName}</option>
          	</c:forEach>
		</select>
    </td>
    <td width="9%" align="right" >需求类别：</td>
    <td width="24%" align="left" >
    	<select name="demindApply.demindType.demindTypeId" style='width:150px'>
			<c:forEach items="${listDemindType}" var="o">
          		<option value="${o.demindTypeId}" <c:if test="${o.demindTypeId eq demindApply.demindType.demindTypeId}">selected="selected"</c:if>>${o.demindTypeName}</option>
          	</c:forEach>
		</select>
    </td>
    <td width="9%" align="right"><span style="color:red;">*</span>期望完成时间：</td>
    <td width="24%" align="left">
    	<input type="text" isNull="期望完成时间" name="demindApply.needCompleteTime" value="<fmt:formatDate value="${demindApply.needCompleteTime}" pattern="yyyy-MM-dd"/>" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',minDate:'<fmt:formatDate value="${currentDate}" pattern="yyyy-MM-dd"/>'});" />
    </td>
  </tr>
  <tr>
    <td align="right"><span style="color:red;">*</span>所属办事处：</td>
    <td align="left">
    	<input type="hidden" id="areaId" name="demindApply.area.areaId" value="${demindApply.area.areaId}"/>
        <input type="text" id="area" isNull="所属办事处" value="${demindApply.area.areaName}"/>
    </td>
  	<td align="right"><span style="color:red;">*</span>所属项目：</td>
    <td align="left">
    	<input type="hidden" id="projectId" name="demindApply.project.projectId" value="${demindApply.project.projectId}"/>
        <input type="text" id="project" isNull="所属项目" value="${demindApply.project.projectName}"/>
    </td>
  	<td align="right">所属客户：</td>
    <td align="left">
        <input type="text" id="clientHide" style="display: none;" readonly="readonly"/>
    	<input type="hidden" id="clientId" name="demindApply.client.clientId" value="${demindApply.client.clientId}"/>
        <input type="text" id="client" isNull="所属客户" value="${demindApply.client.clientName}"/>
    </td>
  </tr>
  <tr>
    <td align="right"><span style="color:red;">*</span>申请负责人：</td>
    <td align="left">
        <input type="text" id="demindApplyDutyuserHide" style="display: none;" readonly="readonly"/>
    	<input type="hidden" id="demindApplyDutyuserId" name="demindApply.demindApplyDutyuser.userId" value="${demindApply.demindApplyDutyuser.userId}"/>
        <input type="text" id="demindApplyDutyuser" isNull="申请负责人" value="${demindApply.demindApplyDutyuser.realName}"/>
    </td>
    <td align="right"><span style="color:red;">*</span>解决负责人：</td>
    <td align="left">
    	<input type="hidden" id="demindSolveDutyuserId" name="demindApply.demindSolveDutyuser.userId" value="${demindApply.demindSolveDutyuser.userId}"/>
        <input type="text" id="demindSolveDutyuser" isNull="解决负责人" value="${demindApply.demindSolveDutyuser.realName}"/>
    </td>
  	<td align="right"><span style="color:red;">*</span>需求申请人：</td>
    <td align="left">
        <input type="text" id="demindApplyUserHide" style="display: none;" readonly="readonly"/>
    	<input type="hidden" id="demindApplyUserId" name="demindApply.demindApplyUser.userId" value="${demindApply.demindApplyUser.userId}"/>
        <input type="text" id="demindApplyUser" isNull="需求申请人" value="${demindApply.demindApplyUser.realName}"/>
    </td>
  </tr>
  <tr>
    <td align="right" ><span style="color:red;">*</span>需求标题：</td>
    <td colspan="5" align="left" >
        <input maxlength="100" style="width:85%;" type="text" value="${demindApply.demindApplyTitle }" name="demindApply.demindApplyTitle" isNull="需求标题" />
    </td>
  </tr>
  <tr>
    <td align="right" >需求正文：</td>
    <td colspan="5" align="left" >
        <textarea rows="3" id="baiduEditor">${demindApply.demindApplyContent}</textarea>
    </td>
  </tr>
  <tr align="right" bgcolor="#F1F1F1">
	<td height="36" colspan="6" align="center">
		<input type='button' class="btn btn-primary" id="btnSave" onclick="save();" value='保存' />
	    &nbsp;<input type='button' class="btn" onclick="turnBack();" value='返回' />
</td>
</tr>
</table>
<input type="hidden" id="demindApplyContent" name="demindApply.demindApplyContent"/>
<input type="hidden" name="demindApply.demindApplyId" value="${demindApply.demindApplyId}"/>
<input type="hidden" name="demindApply.recordCreateTime" value="<fmt:formatDate value="${demindApply.recordCreateTime}" pattern="yyyy-M-d H:m:s"/>" />
</form>
<c:choose>
	<c:when test="${fn:length(listAudit) eq 0}"></c:when>
	<c:otherwise>
	<div class="info_right_main">
	     <table width="100%" border="0" cellspacing="0" cellpadding="0">
		       <tr>
		         <td width="5%" height="35" align="center"><strong>序号</strong></td>
		         <td width="15%" align="center"><strong>审核时间</strong></td>
		         <td width="15%" align="center"><strong>审核人</strong></td>
		         <td width="15%" align="center"><strong>审核结果</strong></td>
		         <td width="50%" align="center"><strong>审核意见</strong></td>
		       </tr>
		       
		       <c:forEach items="${listAudit}" var="audit" varStatus="status">
					<tr align='center' bgcolor="#FFFFFF" onMouseMove="javascript:this.bgColor='#f1f1f1';" onMouseOut="javascript:this.bgColor='#FFFFFF';" height="30" >
						<td>${status.index+1}</td>
						<td><fmt:formatDate value="${audit.auditDate}" pattern="yyyy-MM-dd HH:mm"/></td>
						<td>${audit.user.realName}</td>
						<td><c:choose>
							<c:when test="${audit.auditResult eq 1}">通过</c:when>
							<c:otherwise><b style="color:red">驳回</b></c:otherwise></c:choose></td>
						<td>${audit.auditOpinion}</td>
					</tr>
				</c:forEach>
	     </table>
	</div>
	</c:otherwise>
</c:choose>
<form action="${listUrl}" method="post" style="display: none;" id="refreshForm" name="refreshForm"/>

</body>
</html>
